home *** CD-ROM | disk | FTP | other *** search
- #include <Windows.h>
- #include <QuickDraw.h>
-
- #define wTitleBarColor 4
- #define wTingeLight 11
- #define wTingeDark 12
-
- unsigned short BlendValues(short lightValue, short darkValue);
- void SetupDragHiliteColor(WindowPtr targetWindow);
-
-
- /*-------------------------------------------------------------------------------------
-
- BlendValues
-
- Blend two color values by 27%. Be careful of overflow when multiplying
- a negative number. Output should be light + 27% of difference between light
- and dark.
-
- */
- unsigned short BlendValues(short lightValue, short darkValue)
- {
- register short blender;
-
- blender = darkValue - lightValue;
-
- if ((unsigned long)lightValue > (unsigned long)darkValue)
- blender = -blender; // flip if subtraction would overflow
-
- blender = (unsigned short)((unsigned short)blender * .27);
- // 27% percent multiply
-
- if ((unsigned long)lightValue > (unsigned long)darkValue)
- blender = -blender; // flip it back if it was flipped the
- // first time.
-
- return ((unsigned short)(lightValue + blender));
- }
-
-
- /*-------------------------------------------------------------------------------------
-
- SetupDragHiliteColor
-
- Set the fore color to the color used by the Drag Manager to hilite regions.
-
- */
- void SetupDragHiliteColor(WindowPtr targetWindow)
- {
- RGBColor windowRGB, lightRGB, darkRGB;
- AuxWinHandle auxHandle; // the default AuxWindow data
- CTabHandle winColorTable; // the window color table
- short i, j; // for our color table search
-
- windowRGB.red = 0x8000; // Default to 50% gray.
- windowRGB.green = 0x8000;
- windowRGB.blue = 0x8000;
-
- // If we're using a window which uses System 7's 3D colors
- // then set the hilite color to a tinge for that window.
-
- GetAuxWin(targetWindow, &auxHandle);
-
- // do we have an aux window handle ?
- if (auxHandle != nil) {
- winColorTable = (**auxHandle).awCTable;
-
- // do we have a system 7 sized window color table?
- if ((**winColorTable).ctSize > wTitleBarColor) {
-
- // yes, now search for the tinge color, start at the end
- // because our tinge colors are usually last in the list.
- for (i = (**winColorTable).ctSize; i > 0; i--) {
- if ((**winColorTable).ctTable[i].value == wTingeLight) {
-
- // light tinge found, set the window color to it
- // in case we can't find the dark tinge.
- lightRGB = (**winColorTable).ctTable[i].rgb;
-
- windowRGB.red = lightRGB.red;
- windowRGB.green = lightRGB.green;
- windowRGB.blue = lightRGB.blue;
-
- // we now need the wTingeDark entry to perform a blend.
- // again, search from the end
- for (j = (**winColorTable).ctSize; j > 0; j--)
- if ((**winColorTable).ctTable[j].value == wTingeDark) {
- // dark tinge found. now do the blend
-
- darkRGB = (**winColorTable).ctTable[j].rgb;
-
- windowRGB.red = BlendValues((short)lightRGB.red, (short)darkRGB.red);
- windowRGB.green = BlendValues((short)lightRGB.green, (short)darkRGB.green);
- windowRGB.blue = BlendValues((short)lightRGB.blue, (short)darkRGB.blue);
-
- // if the Color control panel was set to "Black and White", it makes the
- // tinge colors black and black. Use gray in this case
-
- if ((windowRGB.red | windowRGB.green | windowRGB.blue) == 0) {
- windowRGB.red = 0x8000;
- windowRGB.green = 0x8000;
- windowRGB.blue = 0x8000;
- }
-
- j = 0; // bail from inner loop
- }
-
- i = 0; // bail from outer loop
- }
- }
- }
- }
-
- RGBForeColor(&windowRGB); // finally, set it
- }
-
-
-